package tt.dz.egobus.servicemanager.business.key;

import tt.dz.egobus.servicemanager.entities.DriverRegisterBusRelative;

/**
 * @author Anson
 * @date 17-3-23
 * @name redis坐标key的封装
 * @since 1.0.2
 */
public class RedisPointKeyPackage implements StatusKeyPackage {


    private String prefix = "DISTANCE_POINT_";

    private final String driverId;
    private DriverRegisterBusRelative.RelativeStatus status;


    public RedisPointKeyPackage(String driverId, DriverRegisterBusRelative.RelativeStatus status) {
        this.status = status;
        this.driverId = driverId;
    }

    public RedisPointKeyPackage(String driverId) {
        this.driverId = driverId;
    }


    @Override
    public String key() {
        return prefix + (this.status == null ? "" : this.status.getCode() + "_") + this.driverId;
    }

    @Override
    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    @Override
    public String getPrefix() {
        return this.prefix;
    }

    @Override
    public void setStatus(DriverRegisterBusRelative.RelativeStatus codeStatus) {
        this.status = codeStatus == null ? DriverRegisterBusRelative.RelativeStatus.UN_ACTIVE : codeStatus;
    }
}
